/// @tags: NodeDivide
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxn = 1e5 + 3, maxk = 1e7 + 3;

struct Edge {
  int v, nxt, w;
} e[maxn * 2];

int ecnt, m;
int heads[maxn];
int vis[maxn], siz[maxn], maxp[maxn], ans[maxn, k[maxn]];
int buk[maxk];
std::vector<int> d[maxn];

inline void add(int u, int v, int w) {
  e[++ecnt].v = v, e[ecnt].nxt = heads[u];
  e[ecnt].w = w, heads[u] = ecnt;
}

int getRoot(int u, int fa, int ssiz) {
  int rt = 0;
  siz[u] = 1, maxp[u] = 0;
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v != fa && !vis[v]) {
      int vrt = getRoot(v, u, ssiz);
      if (rt == 0 || maxp[vrt] < maxp[rt]) rt = vrt;
      siz[u] += siz[v];
      maxp[u] = std::max(maxp[u], siz[v]);
    }
  }
  maxp[u] = std::max(maxp[u], ssiz - siz[u]);
  if (rt == 0 || maxp[u] < maxp[rt]) rt = u;
  return rt;
}

void dfs(int u, int fa, int dis, int top) {
  d[top].push_back(dis);
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v != fa && !vis[v]) {
      dfs(v, u, dis + e[i].w, top);
    }
  }
}

void solve(int u) {
  vis[u] = true;
  buk[0]++;
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (!vis[v]) dfs(v, u, e[i].w, v);
    for (auto j : d[v]) {
      for (int l = 1; l <= m; ++l)
        if (k[l] >= j) ans[l] |= bool(buk[k[l] - j]);
    }
    for (auto j : d[v]) {
      if (j < maxk) buk[j]++;
    }
  }
  buk[0]--;
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    for (auto j : d[v]) {
      if (j < maxk) buk[j]--;
    }
    d[v].clear();
  }
  for (int i = heads[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (!vis[v]) {
      solve(getRoot(v, v, siz[v]));
    }
  }
}

inline int main() {
  int n;
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    add(u, v, w);
    add(v, u, w);
  }
  for (int i = 1; i <= m; ++i) {
    cin >> k[i];
  }
  solve(getRoot(1, 1, n));
  for (int i = 1; i <= m; ++i) {
    cout << (ans[i] ? "AYE\n" : "NAY\n");
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("NodeDivide.in", "r", stdin);
  freopen("NodeDivide.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
